<br>
<!--留言的展示-->
<% post.comments.forEach(function(comment){ %>
<p>
    <%= comment.name %>
    <span class="info"> 回复于 <%= comment.time %></span>
</p>
<p><%- comment.content %></p>
<% }) %>
<!--添加留言的表单-->
<% if (user) { %>
<form method="post" action="/comment/<%= post.name %>/<%= post.time.minute %>/<%= post.title %>">
    发布人:<%= user.name %>
    <input type="hidden" name="name" value="<%= user.name %>"/><br><br>
    <textarea name="content" rows="5" cols="80"></textarea><br>
    <input type="submit" value="留言"/>
</form>
<% }else{ %>
<form method="post">
    回应请先<a href="/login">登录</a>或<a href="/reg">注册</a>
    <textarea name="content" rows="5" cols="80" id="tb"></textarea><br>
    <input type="submit" value="留言" id="sb"/>
</form>
<% } %>
<script>
    window.onload = function () {
        var textarea = document.querySelector('#tb');
        var button = document.querySelector('#sb');
        button.onclick = function (e) {
            e.preventDefault();
            location.href = '/login';
        }
        textarea.onfocus = function () {
            location.href = '/login';
        }
    }
</script>
